﻿using SvgApplication.Data.Model;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SvgApplication.Authorization
{
    public static class WebUserAccess
    {
        private static ConcurrentDictionary<int, UserRoles> userAccess = new ConcurrentDictionary<int, UserRoles>();

        /// <summary>
        /// sets the access modules for a user
        /// </summary>
        /// <param name="id">user id</param>
        /// <param name="modules">access modules</param>
        public static void SetUserAccess(int id, UserRoles modules)
        {
            userAccess[id] = modules;

        }

        /// <summary>
        /// gets the access modules for a user
        /// </summary>
        /// <param name="id">user id</param>
        /// <returns>access modules</returns>
        public static UserRoles GetUserAccess(int id)
        {
            if (userAccess.ContainsKey(id))
            {
                return userAccess[id];
            }
            return UserRoles.NoAccess;
            //throw new Exception("the user does not exist in the dictionary");
        }
    }
}